package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.Userservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：shirongrong
 * @date ：Created in 2020/3/16
 * @description ：
 * @version: 1.0
 */
@RestController
@RequestMapping("/web/user")
public class UserController {
    @Reference
    private Userservice userService;

    @RequestMapping("/login")
    @ResponseBody
    public Result login(String username, String password){
        try {
            if(userService.login(username,password)){
                return new Result(true, MessageConst.ACTION_SUCCESS,username);
            }

        }catch (Exception e){
            e.printStackTrace();
        }

            return new Result(false,MessageConst.ACTION_FAIL);
        }
    }


